package com.bigbirdmed.cloud.common.core.util;

import com.google.common.collect.Lists;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
@AllArgsConstructor
public class Pagination<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private long total;
    private long size;
    private long current;
    @ApiModelProperty("数据list")
    private List<T> rows;
    @ApiModelProperty("摘要信息")
    private String summary;

    public Pagination() {
        this.size = 10L;
        this.current = 1L;
        this.rows = Lists.newArrayList();
    }

    public Pagination(long current, long size) {
        this.size = 10L;
        this.current = 1L;
        this.rows = Lists.newArrayList();
        if (current > 1L) {
            this.current = current;
        }

        this.size = size;
    }

    public Pagination(long current, long size, long total) {
        this.size = 10L;
        this.current = 1L;
        this.rows = Lists.newArrayList();
        if (current > 1L) {
            this.current = current;
        }
        this.total = total;
        this.size = size;
    }
}

